True if (x, y) is inside a SOLID instance of obj - a raw probe, not tied to any particular instance (e.g. "is this spawn point clear"). Name more objects after the first and it is true if the point is inside a solid instance of any of them.
pos_solid(x, y, obj, ...more) -> bool| Name | Type |
|---|---|
x | real |
y | real |
obj | object |
...more | object (any number of them, none included) |
bool
True if (x, y) is inside a SOLID instance of obj - a raw probe, not tied to any particular instance's own box the way pos_free is tied to the caller's. Useful for "is this spawn point clear" checks that have no instance of their own to test from yet.
x and y are a place in the room, counted from the room's top-left corner.
If obj is a parent, its children count as obj too. With obj_enemy as the parent of obj_slime, a solid slime at the point counts like a solid obj_enemy.
You can name more than one object: pos_solid(x, y, obj_wall, obj_rock) is true when the point is inside a solid instance of any of them.
Only an obj instance with solid set to true counts, the same rule pos_free follows. An object whose Code-tab box Never moves is ticked is answered from a look-up grid instead - same answer, much less work when there are many copies (Never moves).
An instance destroyed earlier in the same frame still counts for this check until the end of the frame, because instance_destroy only ends it then. The one exception is a Collision event, which skips it at once.
An instance with no sprite and no mask size has a box with no size, and a box with no size contains no point, so this never finds one. (Overlap and collision has the whole rule.)
var spawn_x = x + 32;
var spawn_y = y;
if (!pos_solid(spawn_x, spawn_y, obj_doc_wall)) {
instance_create(spawn_x, spawn_y, obj_doc_enemy);
}Only spawns a new obj_doc_enemy 32 pixels to the side if that exact point is not inside a solid obj_doc_wall - independent of the spawner's own size, since pos_solid tests a bare point rather than an instance's box.
Any number of objects may be named; each one is checked together with its children, and an object named twice is checked once.